package com.tuhao.www.serviceImpl;

import com.github.pagehelper.PageInfo;
import com.tuhao.www.dao.BaseDao;
import com.tuhao.www.service.BaseService;
import com.tuhao.www.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;

@Service 
public abstract class BaseServiceImpl<T> implements BaseService<T, Serializable> {
      
    @Autowired  
    private BaseDao<T, Serializable> baseDao;
      
    public BaseDao<T, Serializable> getBaseDao() {  
        return baseDao;  
    }  
    public void setBaseDao(BaseDao<T, Serializable> baseDao) {  
        this.baseDao = baseDao;  
    }  
  
    public int insert(T entity) {  
        return baseDao.insert(entity);  
    } 
    
    @Override
	public int insert(String nameSpace, T record) {
		return baseDao.insert(nameSpace, record);
	}
	public int insertSelective(T record) {  
        return baseDao.insertSelective(record);  
    }  
  
    public T selectByPrimaryKey(Long id) {  
        return baseDao.selectByPrimaryKey(id);  
    }  
  
    public int updateByPrimaryKey(T record) {  
        return baseDao.updateByPrimaryKey(record);  
    }  
  
    public int updateByPrimaryKeySelective(T record) {  
        return baseDao.updateByPrimaryKeySelective(record);  
    }  
  
    @Override
	public int updateByPrimaryKeySelective(Map<String, Object> param) {
    	return baseDao.updateByPrimaryKeySelective(param);
	}
	public int deleteByPrimaryKey(Long id) {  
        return baseDao.deleteByPrimaryKey(id);  
    }  
	
    @Override
	public int delete(String nampSpace, Map<String, Object> param) {
		return baseDao.delete(nampSpace, param);
	}
	public List<T> findTop(int top, String statementKey, Object parameter) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {  
        return baseDao.findTop(top, statementKey, parameter);  
    }  
  
    public T findTopOne(String statementKey, Object parameter) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {  
        return baseDao.findTopOne(statementKey, parameter);  
    }
    
	public PageInfo pageFind(String statementKey, Page page, Object parameter, Boolean isSimplePage) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
		return baseDao.pageFind(statementKey, page, parameter, isSimplePage);
	}
	
	public <M> PageInfo pageFindModel(String statementKey, Page page, Object parameter) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
		return baseDao.pageFindModel(statementKey, page, parameter);
	}
	@Override
	public List<T> selectList(String statementKey, Map<String, Object> param)
			throws IllegalAccessException, InvocationTargetException,
			NoSuchMethodException {
		return baseDao.selectList(statementKey, param);
	}

	@Override
	public <M> PageInfo pageFindModel(String statementKey, Page page,
			Object parameter, Boolean isSimplePage)
			throws IllegalAccessException, InvocationTargetException,
			NoSuchMethodException {
		return baseDao.pageFindModel(statementKey, page, parameter, isSimplePage);
	}
}
